<?php

use yii\helpers\Html;
use yii\grid\GridView;

/* @var $this yii\web\View */
/* @var $searchModel app\models\SysSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '项目管理';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="sys-index">

    <h1><?= Html::encode($this->title) ?></h1>

    <p>
        <?= Html::a('添加项目', ['create'], ['class' => 'btn btn-success']) ?>
    </p>

    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],

            'id',
            'sys_name',
            'gitee',
            'target_dir',
            [
                'class' => 'yii\grid\ActionColumn',
                'template' => '{view} {update} {public}',
                'buttons' => [
                    // 下面代码来自于 yii\grid\ActionColumn 简单修改了下
                    'view' => function ($url, $model, $key) {
                        return Html::a('查看', ['view', 'id' => $model->id], [
                            'class' => 'btn btn-sm btn-info',
                        ]);
                    },
                    'update' => function ($url, $model, $key) {
                        return Html::a('编辑', ['update', 'id' => $model->id], [
                            'class' => 'btn btn-sm btn-info',
                        ]);
                    },
                    'public' => function ($url, $model, $key) {
                        $options = [
                            'title' => Yii::t('yii', 'public'),
                            'aria-label' => Yii::t('yii', 'public'),
                            'data-pjax' => '0',
                            'data' => [
                                'confirm' => '确定要发布项目 '.$model->sys_name.' 吗?',
                                'method' => 'post',
                            ],
                        ];
                        return Html::a('发布', ['public', 'id' => $model->id], [
                            'class' => 'btn btn-sm btn-success',
                            'data' => [
                                'confirm' => '确定要发布项目 '.$model->sys_name.' 吗?',
                                'method' => 'post',
                            ],
                        ]);
                    },
                ]
            ],
        ],
    ]); ?>


</div>
